/*
 * @Author: dadadaXU 1413107032@qq.com
 * @Date: 2025-01-22 21:08:36
 * @LastEditors: dadadaXU 1413107032@qq.com
 * @LastEditTime: 2025-01-22 21:35:51
 * @FilePath: \LeetCode\283.移动零.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/*
 * @lc app=leetcode.cn id=283 lang=cpp
 *
 * [283] 移动零
 */

#include <iostream>
#include <vector>

using namespace std;

// @lc code=start
class Solution
{
public:
    void moveZeroes(vector<int> &nums)
    {
        int len = nums.size();
        int nonzero = 0; // 非零序列长度
        for (auto n : nums)
        {
            if (n != 0)
                nums[nonzero++] = n;
        }
        while (nonzero < len)
            nums[nonzero++] = 0;
    }
};
// @lc code=end

int main(void)
{
    vector<int> nums = {0};

    Solution solution;
    solution.moveZeroes(nums);

    for (auto n : nums)
        cout << n;
    cout << endl;

    return 0;
}